//
// CSkeletonModel.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

import org.ryzom.nel.misc.CRGBA;
import org.ryzom.nel.misc.CVector;

public class CSkeletonModel {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CSkeletonModel(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CSkeletonModel obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        throw new UnsupportedOperationException("C++ destructor does not have public access");
      }
      swigCPtr = 0;
    }
  }

  public static void registerBasic() {
    nel3dJNI.CSkeletonModel_registerBasic();
  }

  public void setBones(SWIGTYPE_p_std__vectorT_NL3D__CBone_t value) {
    nel3dJNI.CSkeletonModel_Bones_set(swigCPtr, this, SWIGTYPE_p_std__vectorT_NL3D__CBone_t.getCPtr(value));
  }

  public SWIGTYPE_p_std__vectorT_NL3D__CBone_t getBones() {
    long cPtr = nel3dJNI.CSkeletonModel_Bones_get(swigCPtr, this);
    return (cPtr == 0) ? null : new SWIGTYPE_p_std__vectorT_NL3D__CBone_t(cPtr, false);
  }

  public IAnimatedValue getValue(long valueId) {
    long cPtr = nel3dJNI.CSkeletonModel_getValue(swigCPtr, this, valueId);
    return (cPtr == 0) ? null : new IAnimatedValue(cPtr, false);
  }

  public String getValueName(long valueId) {
    return nel3dJNI.CSkeletonModel_getValueName(swigCPtr, this, valueId);
  }

  public ITrack getDefaultTrack(long valueId) {
    long cPtr = nel3dJNI.CSkeletonModel_getDefaultTrack(swigCPtr, this, valueId);
    return (cPtr == 0) ? null : new ITrack(cPtr, false);
  }

  public void registerToChannelMixer(CChannelMixer chanMixer, String prefix) {
    nel3dJNI.CSkeletonModel_registerToChannelMixer(swigCPtr, this, CChannelMixer.getCPtr(chanMixer), chanMixer, prefix);
  }

  public static String getSpawnScriptValueName() {
    return nel3dJNI.CSkeletonModel_getSpawnScriptValueName();
  }

  public boolean bindSkin(CTransform mi) {
    return nel3dJNI.CSkeletonModel_bindSkin(swigCPtr, this, CTransform.getCPtr(mi), mi);
  }

  public void stickObject(CTransform mi, long boneId) {
    nel3dJNI.CSkeletonModel_stickObject(swigCPtr, this, CTransform.getCPtr(mi), mi, boneId);
  }

  public void stickObjectEx(CTransform mi, long boneId, boolean forceCLod) {
    nel3dJNI.CSkeletonModel_stickObjectEx(swigCPtr, this, CTransform.getCPtr(mi), mi, boneId, forceCLod);
  }

  public void detachSkeletonSon(CTransform mi) {
    nel3dJNI.CSkeletonModel_detachSkeletonSon(swigCPtr, this, CTransform.getCPtr(mi), mi);
  }

  public void dirtSkinRenderLists() {
    nel3dJNI.CSkeletonModel_dirtSkinRenderLists(swigCPtr, this);
  }

  public SWIGTYPE_p_std__setT_NL3D__CTransform_p_t getSkins() {
    return new SWIGTYPE_p_std__setT_NL3D__CTransform_p_t(nel3dJNI.CSkeletonModel_getSkins(swigCPtr, this), false);
  }

  public SWIGTYPE_p_std__setT_NL3D__CTransform_p_t getStickedObjects() {
    return new SWIGTYPE_p_std__setT_NL3D__CTransform_p_t(nel3dJNI.CSkeletonModel_getStickedObjects(swigCPtr, this), false);
  }

  public void incBoneUsage(long i, CSkeletonModel.TBoneUsageType boneUsageType) {
    nel3dJNI.CSkeletonModel_incBoneUsage(swigCPtr, this, i, boneUsageType.swigValue());
  }

  public void decBoneUsage(long i, CSkeletonModel.TBoneUsageType boneUsageType) {
    nel3dJNI.CSkeletonModel_decBoneUsage(swigCPtr, this, i, boneUsageType.swigValue());
  }

  public void flagBoneAndParents(long boneId, SWIGTYPE_p_std__vectorT_bool_t boneUsage) {
    nel3dJNI.CSkeletonModel_flagBoneAndParents(swigCPtr, this, boneId, SWIGTYPE_p_std__vectorT_bool_t.getCPtr(boneUsage));
  }

  public int getBoneIdByName(String name) {
    return nel3dJNI.CSkeletonModel_getBoneIdByName(swigCPtr, this, name);
  }

  public boolean isBoneComputed(long boneId) {
    return nel3dJNI.CSkeletonModel_isBoneComputed(swigCPtr, this, boneId);
  }

  public boolean forceComputeBone(long boneId) {
    return nel3dJNI.CSkeletonModel_forceComputeBone(swigCPtr, this, boneId);
  }

  public long getNumBoneComputed() {
    return nel3dJNI.CSkeletonModel_getNumBoneComputed(swigCPtr, this);
  }

  public void setInterpolationDistance(float dist) {
    nel3dJNI.CSkeletonModel_setInterpolationDistance(swigCPtr, this, dist);
  }

  public float getInterpolationDistance() {
    return nel3dJNI.CSkeletonModel_getInterpolationDistance(swigCPtr, this);
  }

  public SWIGTYPE_p_NLMISC__CMatrix getActiveBoneSkinMatrix(long boneId) {
    return new SWIGTYPE_p_NLMISC__CMatrix(nel3dJNI.CSkeletonModel_getActiveBoneSkinMatrix(swigCPtr, this, boneId), false);
  }

  public void computeAllBones(SWIGTYPE_p_NLMISC__CMatrix modelWorldMatrix) {
    nel3dJNI.CSkeletonModel_computeAllBones(swigCPtr, this, SWIGTYPE_p_NLMISC__CMatrix.getCPtr(modelWorldMatrix));
  }

  public boolean computeRenderedBBox(SWIGTYPE_p_NLMISC__CAABBox bbox, boolean computeInWorld) {
    return nel3dJNI.CSkeletonModel_computeRenderedBBox__SWIG_0(swigCPtr, this, SWIGTYPE_p_NLMISC__CAABBox.getCPtr(bbox), computeInWorld);
  }

  public boolean computeRenderedBBox(SWIGTYPE_p_NLMISC__CAABBox bbox) {
    return nel3dJNI.CSkeletonModel_computeRenderedBBox__SWIG_1(swigCPtr, this, SWIGTYPE_p_NLMISC__CAABBox.getCPtr(bbox));
  }

  public boolean computeRenderedBBoxWithBoneSphere(SWIGTYPE_p_NLMISC__CAABBox bbox, boolean computeInWorld) {
    return nel3dJNI.CSkeletonModel_computeRenderedBBoxWithBoneSphere__SWIG_0(swigCPtr, this, SWIGTYPE_p_NLMISC__CAABBox.getCPtr(bbox), computeInWorld);
  }

  public boolean computeRenderedBBoxWithBoneSphere(SWIGTYPE_p_NLMISC__CAABBox bbox) {
    return nel3dJNI.CSkeletonModel_computeRenderedBBoxWithBoneSphere__SWIG_1(swigCPtr, this, SWIGTYPE_p_NLMISC__CAABBox.getCPtr(bbox));
  }

  public boolean computeCurrentBBox(SWIGTYPE_p_NLMISC__CAABBox bbox, boolean forceCompute, boolean computeInWorld) {
    return nel3dJNI.CSkeletonModel_computeCurrentBBox__SWIG_0(swigCPtr, this, SWIGTYPE_p_NLMISC__CAABBox.getCPtr(bbox), forceCompute, computeInWorld);
  }

  public boolean computeCurrentBBox(SWIGTYPE_p_NLMISC__CAABBox bbox, boolean forceCompute) {
    return nel3dJNI.CSkeletonModel_computeCurrentBBox__SWIG_1(swigCPtr, this, SWIGTYPE_p_NLMISC__CAABBox.getCPtr(bbox), forceCompute);
  }

  public boolean computeCurrentBBox(SWIGTYPE_p_NLMISC__CAABBox bbox) {
    return nel3dJNI.CSkeletonModel_computeCurrentBBox__SWIG_2(swigCPtr, this, SWIGTYPE_p_NLMISC__CAABBox.getCPtr(bbox));
  }

  public String getSpawnScript() {
    return nel3dJNI.CSkeletonModel_getSpawnScript(swigCPtr, this);
  }

  public void setSpawnScript(String s) {
    nel3dJNI.CSkeletonModel_setSpawnScript(swigCPtr, this, s);
  }

  public void setSSSWOPos(CVector pos) {
    nel3dJNI.CSkeletonModel_setSSSWOPos(swigCPtr, this, CVector.getCPtr(pos), pos);
  }

  public CVector getSSSWOPos() {
    return new CVector(nel3dJNI.CSkeletonModel_getSSSWOPos(swigCPtr, this), false);
  }

  public void setSSSWODir(CVector dir) {
    nel3dJNI.CSkeletonModel_setSSSWODir(swigCPtr, this, CVector.getCPtr(dir), dir);
  }

  public CVector getSSSWODir() {
    return new CVector(nel3dJNI.CSkeletonModel_getSSSWODir(swigCPtr, this), false);
  }

  public CSkeletonSpawnScript getSSSScript() {
    return new CSkeletonSpawnScript(nel3dJNI.CSkeletonModel_getSSSScript(swigCPtr, this), false);
  }

  public boolean fastIntersect(CVector p0, CVector dir, SWIGTYPE_p_float dist2D, SWIGTYPE_p_float distZ, boolean computeDist2D) {
    return nel3dJNI.CSkeletonModel_fastIntersect(swigCPtr, this, CVector.getCPtr(p0), p0, CVector.getCPtr(dir), dir, SWIGTYPE_p_float.getCPtr(dist2D), SWIGTYPE_p_float.getCPtr(distZ), computeDist2D);
  }

  public void remapSkinBones(Vector_String bonesName, SWIGTYPE_p_std__vectorT_int_t bonesId, Vector_uint16 remap) {
    nel3dJNI.CSkeletonModel_remapSkinBones(swigCPtr, this, Vector_String.getCPtr(bonesName), bonesName, SWIGTYPE_p_std__vectorT_int_t.getCPtr(bonesId), Vector_uint16.getCPtr(remap), remap);
  }

  public void enableLOD(boolean isEnable) {
    nel3dJNI.CSkeletonModel_enableLOD(swigCPtr, this, isEnable);
  }

  public void setLodCharacterShape(int shapeId) {
    nel3dJNI.CSkeletonModel_setLodCharacterShape(swigCPtr, this, shapeId);
  }

  public int getLodCharacterShape() {
    return nel3dJNI.CSkeletonModel_getLodCharacterShape(swigCPtr, this);
  }

  public void setLodCharacterAnimId(long animId) {
    nel3dJNI.CSkeletonModel_setLodCharacterAnimId(swigCPtr, this, animId);
  }

  public long getLodCharacterAnimId() {
    return nel3dJNI.CSkeletonModel_getLodCharacterAnimId(swigCPtr, this);
  }

  public void setLodCharacterAnimTime(double time) {
    nel3dJNI.CSkeletonModel_setLodCharacterAnimTime(swigCPtr, this, time);
  }

  public double getLodCharacterAnimTime() {
    return nel3dJNI.CSkeletonModel_getLodCharacterAnimTime(swigCPtr, this);
  }

  public void setLodCharacterWrapMode(boolean wrapMode) {
    nel3dJNI.CSkeletonModel_setLodCharacterWrapMode(swigCPtr, this, wrapMode);
  }

  public boolean getLodCharacterWrapMode() {
    return nel3dJNI.CSkeletonModel_getLodCharacterWrapMode(swigCPtr, this);
  }

  public boolean isDisplayedAsLodCharacter() {
    return nel3dJNI.CSkeletonModel_isDisplayedAsLodCharacter(swigCPtr, this);
  }

  public void setLodCharacterDistance(float dist) {
    nel3dJNI.CSkeletonModel_setLodCharacterDistance(swigCPtr, this, dist);
  }

  public float getLodCharacterDistance() {
    return nel3dJNI.CSkeletonModel_getLodCharacterDistance(swigCPtr, this);
  }

  public float computeDisplayLodCharacterPriority() {
    return nel3dJNI.CSkeletonModel_computeDisplayLodCharacterPriority(swigCPtr, this);
  }

  public void setDisplayLodCharacterFlag(boolean displayCLod) {
    nel3dJNI.CSkeletonModel_setDisplayLodCharacterFlag(swigCPtr, this, displayCLod);
  }

  public void computeLodTexture() {
    nel3dJNI.CSkeletonModel_computeLodTexture(swigCPtr, this);
  }

  public void setLodEmit(CRGBA emit) {
    nel3dJNI.CSkeletonModel_setLodEmit(swigCPtr, this, CRGBA.getCPtr(emit), emit);
  }

  public CRGBA getLodEmit() {
    return new CRGBA(nel3dJNI.CSkeletonModel_getLodEmit(swigCPtr, this), true);
  }

  public float getNumTriangles(float distance) {
    return nel3dJNI.CSkeletonModel_getNumTriangles(swigCPtr, this, distance);
  }

  public void changeMRMDistanceSetup(float distanceFinest, float distanceMiddle, float distanceCoarsest) {
    nel3dJNI.CSkeletonModel_changeMRMDistanceSetup(swigCPtr, this, distanceFinest, distanceMiddle, distanceCoarsest);
  }

  public void resetDefaultMRMDistanceSetup() {
    nel3dJNI.CSkeletonModel_resetDefaultMRMDistanceSetup(swigCPtr, this);
  }

  public void traverseAnimDetail() {
    nel3dJNI.CSkeletonModel_traverseAnimDetail(swigCPtr, this);
  }

  public void traverseRender() {
    nel3dJNI.CSkeletonModel_traverseRender(swigCPtr, this);
  }

  public void getLightHotSpotInWorld(CVector modelPos, SWIGTYPE_p_float modelRadius) {
    nel3dJNI.CSkeletonModel_getLightHotSpotInWorld(swigCPtr, this, CVector.getCPtr(modelPos), modelPos, SWIGTYPE_p_float.getCPtr(modelRadius));
  }

  public void setBoneAnimCtrl(long boneId, IAnimCtrl ctrl) {
    nel3dJNI.CSkeletonModel_setBoneAnimCtrl(swigCPtr, this, boneId, IAnimCtrl.getCPtr(ctrl), ctrl);
  }

  public IAnimCtrl getBoneAnimCtrl(long boneId) {
    long cPtr = nel3dJNI.CSkeletonModel_getBoneAnimCtrl(swigCPtr, this, boneId);
    return (cPtr == 0) ? null : new IAnimCtrl(cPtr, false);
  }

  public void generateShadowMap(CVector lightDir) {
    nel3dJNI.CSkeletonModel_generateShadowMap(swigCPtr, this, CVector.getCPtr(lightDir), lightDir);
  }

  public CShadowMap getShadowMap() {
    long cPtr = nel3dJNI.CSkeletonModel_getShadowMap(swigCPtr, this);
    return (cPtr == 0) ? null : new CShadowMap(cPtr, false);
  }

  public boolean computeWorldBBoxForShadow(SWIGTYPE_p_NLMISC__CAABBox worldBB) {
    return nel3dJNI.CSkeletonModel_computeWorldBBoxForShadow(swigCPtr, this, SWIGTYPE_p_NLMISC__CAABBox.getCPtr(worldBB));
  }

  public void renderIntoSkeletonShadowMap(CSkeletonModel rootSkeleton, CMaterial castMat) {
    nel3dJNI.CSkeletonModel_renderIntoSkeletonShadowMap(swigCPtr, this, CSkeletonModel.getCPtr(rootSkeleton), rootSkeleton, CMaterial.getCPtr(castMat), castMat);
  }

  public void getWorldMaxBoneSpheres(SWIGTYPE_p_std__vectorT_NLMISC__CBSphere_t dest) {
    nel3dJNI.CSkeletonModel_getWorldMaxBoneSpheres(swigCPtr, this, SWIGTYPE_p_std__vectorT_NLMISC__CBSphere_t.getCPtr(dest));
  }

  public void updateSkinRenderLists() {
    nel3dJNI.CSkeletonModel_updateSkinRenderLists(swigCPtr, this);
  }

  public final static int MaxNumBones = nel3dJNI.CSkeletonModel_MaxNumBones_get();

  public final static class TAnimValues {
    public final static TAnimValues OwnerBit = new TAnimValues("OwnerBit", nel3dJNI.CSkeletonModel_OwnerBit_get());
    public final static TAnimValues SpawnScriptValue = new TAnimValues("SpawnScriptValue");
    public final static TAnimValues AnimValueLast = new TAnimValues("AnimValueLast");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TAnimValues swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TAnimValues.class + " with value " + swigValue);
    }

    private TAnimValues(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TAnimValues(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TAnimValues(String swigName, TAnimValues swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TAnimValues[] swigValues = { OwnerBit, SpawnScriptValue, AnimValueLast };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

  public final static class TBoneUsageType {
    public final static TBoneUsageType UsageNormal = new TBoneUsageType("UsageNormal");
    public final static TBoneUsageType UsageForced = new TBoneUsageType("UsageForced");
    public final static TBoneUsageType UsageCLodForced = new TBoneUsageType("UsageCLodForced");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TBoneUsageType swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TBoneUsageType.class + " with value " + swigValue);
    }

    private TBoneUsageType(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TBoneUsageType(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TBoneUsageType(String swigName, TBoneUsageType swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TBoneUsageType[] swigValues = { UsageNormal, UsageForced, UsageCLodForced };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
